/**
 * @author tongchen
 * @create 2023-02-03 21:41
 */
public class HanoiTowerTest {
    private static int count=0;
    public static void printHanoiTower(int x,String from ,String by,String to){
        //当只有一个的时候直接移动即可
        if(x==1){
            System.out.println(x+"从"+from+"移动到"+to+(++count));
            return;
        }
        //将x-1个经过to移动到by
        printHanoiTower(x-1, from, to, by);
        //将x从from经过by移动到to
        System.out.println(x+"从"+from+"移动到"+to+(++count));
        //n-1个从by经过to移动到from
        printHanoiTower(x-1, by,from , to);
    }

    public static void main(String[] args) {
        printHanoiTower(5 , "A", "C", "B");
    }
}
